package com.smq.chatserver.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smq.chatserver.bean.TeemMember;
import com.smq.chatserver.mapper.TeemMemberMapper;
import com.smq.chatserver.services.TeemMemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
@Slf4j
public class TeemMemberServiceImpl extends ServiceImpl<TeemMemberMapper, TeemMember> implements TeemMemberService {

    @Autowired
    TeemMemberMapper teemMemberMapper;

    @Override
    public List<TeemMember> query(String teemId) {
        return teemMemberMapper.selectList(new QueryWrapper<TeemMember>().eq("teem_id", teemId));
    }

    @Override
    public TeemMember create(String teemId, String userId, String nick, int mute) {
        TeemMember teemMember = new TeemMember(teemId + "-" + userId, teemId, userId, nick, mute, System.currentTimeMillis());
        teemMemberMapper.insert(teemMember);
        return teemMember;
    }
}
